package org.example.qqrobot.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.example.qqrobot.model.pojo.Message;

import java.util.List;

@Mapper
public interface MessageMapper {


    @Insert("insert into message(sender, receiver, send_time, content, status) values (#{sender},#{receiver},#{sendTime},#{content},#{status})")
    void save(Message message1);

    @Select("select *from message where receiver = #{currentId}")
    List<Message> findByReceiverId(Long currentId);

    @Select("select sender from message where id = #{id}")
    Long findSenderById(Long id);

    @Select("select *from message where id = #{id}")
    Message findById(Long id);

    @Update("update message set status = #{status} where id = #{id}")
    void update(Message message);
}
